package com.vidaappv1;

import java.util.ArrayList;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.RadioButton;
import android.widget.Toast;

public class LoadCredits extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_load_credits);
		
		final ArrayList<RadioButton> rb = new ArrayList<RadioButton>();
		Button accountinfobutton = (Button)findViewById(R.id.button1);
		Button creditcardeditbutton = (Button)findViewById(R.id.btnTakeAway);
		Button loadcreditsbutton = (Button)findViewById(R.id.btnSitDown);
		final RadioButton rdbuttonR20 = (RadioButton)findViewById(R.id.radioButton4);
		final RadioButton rdbuttonR50 = (RadioButton)findViewById(R.id.radioButton5);
		final RadioButton rdbuttonR100 = (RadioButton)findViewById(R.id.radioButton6);
		final RadioButton rdbuttonR200 = (RadioButton)findViewById(R.id.radioButton7);

		
		accountinfobutton.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				startActivity(new Intent(getApplicationContext(),AccountInfo.class));
			}
		});
		
		creditcardeditbutton.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				Toast.makeText(getApplicationContext(), "This function has been disabled.", Toast.LENGTH_LONG).show();

				
			}
		});
	
		loadcreditsbutton.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				int topupamount = 0;
				Intent topupintent =new Intent(getApplicationContext(),CreditsLoaded.class);
				
				if(rdbuttonR20.isChecked()){
					topupintent.putExtra("Top up amount",topupamount);
					startActivity(topupintent);

				}
				else if (rdbuttonR50.isChecked()){
					topupamount = 50;
					topupintent.putExtra("Top up amount",topupamount);
					startActivity(topupintent);

				}
				else if (rdbuttonR100.isChecked()){
					topupamount = 100;
					topupintent.putExtra("Top up amount",topupamount);
					startActivity(topupintent);

				}
				else if (rdbuttonR200.isChecked()){
					topupamount = 200;
					topupintent.putExtra("Top up amount",topupamount);
					startActivity(topupintent);

				}
				else{
					Toast.makeText(getApplicationContext(), "Select an amount then tap LOAD", Toast.LENGTH_LONG).show();
				}
					
				
			}
		});
		
		
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.load_credits, menu);
		return true;
	}

}
